home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
xmem.arc
/
XMEM.ASM
next >
Wrap
Assembly Source File
|
1986-01-24
|
3KB
|
103 lines
PTOTAL EQU 42H ;DEFINE EMM FUNCTION CODES
PCOUNT EQU 4BH
PBYPROC EQU 4DH
DISPLAY MACRO ;DISPLAY STRING AT DS:SI
MOV DX,DI
MOV AH,9
INT 21H
ENDM
EMMCALL MACRO FUNCT
LOCAL NOERR
MOV AH,FUNCT
INT 67H ;PERFORM EMM FUNCTION
OR AH,AH ;TEST FOR ERRORS
JZ NOERR
LEA DI,ERR$ ;IF ERROR, EXIT W/MESSAGE
JMP EXIT
NOERR: ;CONTINUE HERE IF NO ERROR
ENDM
CODE SEGMENT
ASSUME CS:CODE, DS:CODE, ES:CODE
ORG 100H
XMEM PROC
JMP PASTDATA
ERR$ DB 'Expanded Memory Error',13,10,'$'
TOTALK$ DB ' 0 K Total Expanded Memory',13,10,'$'
EACHK$ DB ' K used by process'
PRNUM$ DB 0,0,0,0,0,0,13,10,'$'
FREE$ DB ' K free',13,10,'$'
EMMNAME DB 'EMMXXXX0' ;NAME OF EMM DEVICE DRIVER
FREEPAGES DW 0 ;UNALLOCATED PAGE COUNT
PAGES DW 256 DUP (0,0) ;ARRAY OF PAGE COUNTS
PASTDATA: PUSH ES
MOV AX,3567H ;GET INT 67 VECTOR
INT 21H
MOV DI,10 ;POINT TO DEVICE NAME
LEA SI,EMMNAME ;POINT TO EMM NAME
MOV CX,8
CLD
REPE CMPSB ;IS EMM INSTALLED?
LEA DI,TOTALK$ ;MSG IN CASE IT ISN'T
JNE EXIT ;EXIT IF NO EMM
POP ES
EMMCALL PTOTAL ;DETERMINE TOTAL PAGE COUNT
MOV AX,DX ;PAGE COUNT RETURNED IN DX
MOV FREEPAGES,AX ;SAVE IT
LEA DI,TOTALK$
CALL P2K ;CONVERT PAGES TO K
DISPLAY
LEA DI,PAGES ;POINT TO ARRAY OF PAGE COUNTS
EMMCALL PBYPROC ;GET PAGES PER PROCESS EjE
EMMCALL PCOUNT ;GET EMM PROCESS COUNT
MOV CX,BX ;PROCESS COUNT TO CX
JCXZ X2 ;SKIP IF NO EMM PROCESSES
MOV SI,DI ;POINT SI TO PAGE ARRAY
X1: LODSW ;GET PROCESS ID
CBW ;CONVERT LOW BYTE ONLY
LEA DI,PRNUM$
CALL I2ASC ;CONVERT # TO ASCII
LODSW ;GET PAGES FOR THIS PROCESS
SUB FREEPAGES,AX ;UPDATE FREE PAGE COUNT
LEA DI,EACHK$
CALL P2K ;CONVERT PAGES TO ASCII K
DISPLAY ;DISPLAY PROCESS COUNT
LOOP X1 ;CONTINUE FOR ALL PROCESSES
X2: MOV AX,FREEPAGES
LEA DI,FREE$
CALL P2K
EXIT: DISPLAY ;DISPLAY LAST MESSAGE
INT 20H ;THAT'S ALL, FOLKS
XMEM ENDP
P2K PROC
SHL AX,1 ;KBYTES = PAGES * 16
SHL AX,1
SHL AX,1
SHL AX,1
I2ASC: PUSH DI ;ENTER HERE IF # IS NOT PAGES
PUSH CX
CLD
PUSH AX
MOV AL,' ' ;BLANK OUT STRING
MOV CX,6
REP STOSB
DEC DI ;POINT AT STRING END
MOV BX,10 ;BASE TEN DIVISOR
POP AX ;GET BINARY NUMBER INTO AX
STD ;MOVE BACKWARDS THRU STRING
DIVLOOP: CWD ;CONVERT TO DBL WORD IN DX,AX
DIV BX ;QUOTIENT IN AX, REMNDR IN DX
XCHG AX,DX ;EXCHANGE QUOT & REM
OR AX,30H ;CONVERT TO ASCII CHAR IN STRING
STOSB ;STORE ASCII CHAR IN STRING
MOV AX,DX ;RESTORE QUOTIENT TO AX
OR AX,AX ;TEST IF MORE DEC DIGITS
JNZ DIVLOOP
POP CX ;RESTORE & EXIT
POP DI
CLD
RET
P2K ENDP
CODE ENDS
END XMEM